import requests as req

def getTranslation(words):
    url='https://fanyi.baidu.com/sug'
    headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'}
    res= req.post(url=url,params={'kw':words},headers=headers)
    return res.json()

def main():
    words=input('请输入要翻译的中文\n')
    result=getTranslation(words)
    data=result.get('data')
    print('已得到以下结果：\n')
    for i in data:
        key=i.get('k')
        value=i.get('v')
        print("{}\t{}\n".format(key,value))
    

main()